#! /user/bin/python3
# coding=utf-8
# @Time:2024/7/4 0:24
# @Author:WentR
# 读取yaml文件中的数据

# file = open("D:\桌面作业文件\Auto\config\environment.yaml", encoding="utf-8")
# try:
#     a = file.read()
#     print(a)
# except Exception as e:
#     print(e)
# finally:
#     file.close()
# readlines是每次读取文件的一行存入列表中
# read是读取整个文件
# with open("D:\桌面作业文件\Auto\config\environment.yaml", "r", encoding="utf-8") as file:
#     for i in file.readlines():
#         print("=====")
#         print(i)
#     # a = file.read()
#     # print(a)
import yaml

import yaml
from tools import get_project_path, sep


class GetConf:
    def __init__(self):
        project_dir = get_project_path()
        with open(project_dir + sep(['config', 'environment.yaml'], add_sep_before=True), "r", encoding="utf-8") as env_file:
            self.env = yaml.load(env_file, Loader=yaml.FullLoader)
            print(self.env)

    def get_username_password(self):
        return self.env["username"], self.env["password"]


if __name__ == '__main__':
    GetConf().get_username_password()
